package com.cn.组件条件注册;

import com.cn.组件注册.old.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * @Auther: 代理仁
 * @Date: 2019/7/7 22:40
 * @Description:根据条件注册
 */
@Configuration
public class ConditionConfig {
    //@Conditional:根据条件注册组件,参数是数组,条件由自己定义必须实现Condition接口
    @Conditional({OuShuCondition.class})
    @Bean
    public User oushu(){
        return new User(2,"偶数");
    }
    @Conditional({JiShuCondition.class})
    @Bean
    public User jishu(){
        return new User(3,"奇数");
    }
}
